%%%%%%%%%%%%%%%%%%%%% chapter.tex %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% chapter0
%
% 
%
%%%%%%%%%%%%%%%%%%%%%%%% Springer-Verlag %%%%%%%%%%%%%%%%%%%%%%%%%%
%\motto{Use the template \emph{chapter.tex} to style the various elements of your chapter content.}
\chapsubtitle{Books and tools}
\chapter{Get Prepared}
\label{chap1} % Always give a unique label
% use \chaptermark{}
% to alter or adjust the chapter heading in the running head
\section{Books}
\label{1.1}
When people talk about the compiler techniques, the first book probably everyone will come up with is the \emph{ Dragon Book - Compilers: Principles, Techniques, and Tools}. Although more than two decades have passed since the publication of the first edition, it is widely regarded as the classic definitive compiler technology text.  The first edition of the book was published in 1986, and informally known as the \emph{Red dragon}. We are going to use the second edition, which is generally known as \emph{Purple dragon}. 

This is a classic book, as everyone in the field should have it. Or even just put it on the shelf.
\begin{svgraybox}
Aho, Lam, Sethi and Ullman,  \emph{Compilers: Principles, Techniques, and Tools}, Addison-Wesley, 1986. ISBN0-201-10088-6
\end{svgraybox}
Another book we will use is \emph{lex \& yacc}. \emph{Lex} and \emph{Yacc} are the tools we will use to write the compiler, and this book teaches us how to use these tools. The updated version of \emph{lex} is \emph{flex}, and the update version of \emph{yacc} is \emph{bison}.  Hence the book is also updated with the new name \emph{flex \& bison}. This little book really helps a lot when I first using \emph{flex \& bison}. The handy examples in the book are small, but elegant, and worth reading.
\begin{svgraybox}
Levine,  \emph{Flex \& Bison: Text Processing Tools}, O'Reilly Media, 2009. ISBN0-596-15597-2
\end{svgraybox}

\section{Tools}
\label{1.2}
The preferred language for the projects is \emph{C}, and the best working environment is \emph{Unix}.
\newline
We will use \emph{flex} to write a lexical analyzer. The latest version of the tool and documentation can be found at
\begin{svgraybox}
\url{http://flex.sourceforge.net/}
\end{svgraybox}

And use \emph{bison} to write a syntax analyzer. Which can be found at
\begin{svgraybox}
\url{http://www.gnu.org/s/bison/}
\end{svgraybox}
When install them, open terminal, then type
\begin{svgraybox}
\\./configure  $\langle$ path you want to install $\rangle$
\\./make
\\./make install
\end{svgraybox}
Make sure you have root permission to do this.

If you are using Java, then you should use \emph{jflex} and \emph{byacc/j} instead.
\newline
\emph{JFlex} is a version of \emph{lex}, which generates Java code and is also written in Java. \emph{JFlex} and its complete documentation can be found at
\begin{svgraybox} 
\url{http://jflex.de}
\end{svgraybox}
\emph{Byacc/j} is an extension of \emph{byacc} (Berkeley \emph{yacc}), which will, as an option, generate Java code. It can be found, along with documentation, at
\begin{svgraybox} 
\url{http://byaccj.sourceforge.net}
\end{svgraybox}
If you are working on a PC based on Microsoft Windows, then use the tools list below.
\newline
\indent
The DOS port of \emph{flex} and \emph{bison} can be found at
\begin{svgraybox}
\url{http://www.delorie.com/pub/djgpp/current/v2gnu/flx254b.zip}
\\and 
\\\url{http://www.delorie.com/pub/djgpp/current/v2gnu/bsn21b.zip}
\end{svgraybox}
The development environment for them is the djgpp, which can be accessed from
\begin{svgraybox}
\url{http://www.delorie.com/djgpp}
\end{svgraybox}
However the djgpp only works on 32bit OS, so if you have a 64bit OS, download the collection of Unix utilities (including \emph{flex} and \emph{bison}) instead.
\begin{svgraybox}
\url{http://sourceforge.net/projects/unxutils/}
\end{svgraybox}
There are also some other \emph{gcc} ports for windows
\newline
\indent
MinGW, works on 64-bit Windows. It is available at:
\begin{svgraybox}
\url{http://www.mingw.org}
\end{svgraybox}
Cygwin provides gcc/g++ along with a Unix-like environment. Read about it at
\begin{svgraybox}
\url{http://www.cygwin.com/}
\end{svgraybox}

\section{Editors}
\label{1.3}
If you working on a Mac, \emph{Xcode} is something you must install, by installing the \emph{Xcode}, you will also fully install the \emph{gcc}. And \emph{Xcode} natively supports \emph{C}.  You can get \emph{Xcode} directly from the Mac AppStore for free.

We will use \emph{flex} and \emph{bison}, whose pattern is not recognized by the regular \emph{C} IDE.  So it’s practical just use plain text editors to edit \emph{flex} or \emph{bison} files. However, \emph{flex} and \emph{bison} provide detailed error messages, so a text editor featured with line numbers will do a better job.

\emph{TextWrangler} is a simple yet powerful text editor on Mac, it can be found free in the Mac AppStore. I also wrote a \emph{TextWrangler} language module for \emph{PAXI}. You can get it from my website.

If you work on the MS Windows, Notepad++ is something similar. Check it out at
\begin{svgraybox}
\url{http://notepad-plus-plus.org/}
\end{svgraybox}

But what if you are a big terminal fan?  Use \emph{emacs}. \emph{Emacs} is GNU software. It is an extendable and customizable text editor, but the core of it is the interpreter of \emph{Emacs Lisp}. The official site is
\begin{svgraybox}
\url{http://www.gnu.org/s/emacs/}
\end{svgraybox}
Windows port emacs is also available at
\begin{svgraybox}
\url{http://www.gnu.org/software/emacs/windows/}
\end{svgraybox}

If you prefer something simpler, you can try the \emph{vim}, the improved version of \emph{vi}. It's native on unix, which means it's native in the GMU cloud.  You can find versions for other OS at
\begin{svgraybox}
\url{http://www.vim.org}
 \end{svgraybox}

Want simpler? Go for \emph{pico} or check out the free software list from FSF(free software foundation)
\begin{svgraybox}
\url{http://directory.fsf.org/wiki/Main_Page}
 \end{svgraybox}

\section{Useful resources}
\label{1.4}

Companies like Microsoft and Apple are the dominated kings of PC. People even do not have the power over their own computer. Also the incredible high price of the software makes it even harder and more expensive for people using computer. So people mainly use pirate software. It's not only the violation of intellectual property laws but also put the computer under high risk of virus and worms. There should be a better way and there is a better way-free software and open source software. I strongly believe these communities have the most intelligent and creative programmers ever, and will change the future of software industry. Some most active communities and websites are listed below.

FSF short for free software foundation is a community promote free software, also it drives the development of GNU. You can found lots of wonderful stuff from 
\begin{svgraybox}
\url{http://www.fsf.org}
 \end{svgraybox}
FSF also provide useful online manuals at 
\begin{svgraybox}
\url{http://www.fsf.org/manual/manual.html}
 \end{svgraybox}

GNU is a project begins in 1984. The goal is to develop a completely Unix-Like system. The most important is, it's free software. The tools we use, like \emph{flex}, \emph{bison}, \emph{emacs} are all parts of GNU OS. The GNU is often used with a kernel called \emph{linux}. The combine of GNU and \emph{linux} is the GNU/Linux OS, which now used by millions and sometimes incorrectly called simply \emph{Linux}. Well, now you know it. The official site of this project is
\begin{svgraybox}
\url{http://www.gnu.org/}
 \end{svgraybox} 

SourceForge is a web-based source code repository. It acts as a centralized location for software developers to control and manage open source software development. As of July 2011, the SourceForge repository hosts more than 300,000 projects and has more than 2 million registered users. Explore more at:
\begin{svgraybox}
\url{http://sourceforge.net/}
 \end{svgraybox}

